package com.maoye.ossp.bpm.defmanager.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;

import com.hotent.bpmx.api.def.BpmDefinitionAccessor;
import com.hotent.bpmx.api.model.process.nodedef.BpmNodeDef;
import com.hotent.bpmx.api.service.BpmDefinitionService;
import com.maoye.ossp.common.web.BaseController;

/**
 * 公式定义器控制器
 * 
 * @author zxpfss
 * 
 */
@Controller
@RequestMapping("/bpm/formula")
public class BpmFormulaController extends BaseController {

	// ----------------------属性-------------------------

	private static Logger logger = Logger.getLogger(BpmNodeDefController.class);
	// 控制器路径
	protected final String rootPath;

	public BpmFormulaController() {
		logger.debug("加载流程根路径");
		RequestMapping rootMapping = AnnotationUtils.findAnnotation(this.getClass(), RequestMapping.class);
		if (rootMapping != null) {
			String rp = rootMapping.value()[0];
			rootPath = rp;
		} else {
			rootPath = "";
		}
	}

	// ----------------------public-------------------------
	/**
	 * 显示公式定义器
	 * @param request
	 * @return
	 */
	@RequestMapping("/view")
	public ModelAndView view(WebRequest request) {
		try {
//			String idField = (String)request.getAttribute("idField", WebRequest.SCOPE_REQUEST);
//			request.setAttribute("idField", idField, WebRequest.SCOPE_REQUEST);
			request.setAttribute("proDefId", request.getAttribute("proDefId", WebRequest.SCOPE_REQUEST), WebRequest.SCOPE_REQUEST);
			return new ModelAndView(rootPath + "/formula");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	// ----------------------private-------------------------

	// ----------------------get/set-------------------------
}
